<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jstl/core" 
	xmlns:v="http://www.oschina.net/" >
	<p:dialog header="修改用户信息" widgetVar="userdataDlgVar" showEffect="fade" 
		hideEffect="fade" modal="true" resizable="false" id="userdataDlgId">
		<p:ajax event="close" update=":userinfoFormId:growl" />
		<h:form id="userdataFormId" prependId="false">
			<h:panelGrid columns="4"
				columnClasses="column1,column2,column1,column2">
				<h:outputText value="用户帐号：" />
				<p:inputText value="#{userinfoBean.userinfo.account}" disabled="#{userinfoBean.isModify}" label="用户帐号" required="true">
					<f:validator validatorId="customValidator" />
					<f:attribute name="empty" value="true" />
					<f:attribute name="min" value="4" />
					<f:attribute name="regex" value="ONLYEN" />
				</p:inputText>
				
				<h:outputText value="用户密码：" />
				<p:inputText value="#{userinfoBean.userinfo.password}"   label="用户密码" required="true">
					<f:validator validatorId="customValidator" />
					<f:attribute name="empty" value="true" />
					<f:attribute name="min" value="4" />
				</p:inputText>
				
				<h:outputText value="真实姓名：" />
				<p:inputText value="#{userinfoBean.userinfo.realname}" maxlength="3" id="realNameId" label="真实姓名" validatorMessage="真实姓名：最小长度不能小于2个字符。">
					<f:validateLength minimum="2" />
				</p:inputText>
				
				<h:outputText value="用户年龄：" />
				<p:inputText value="#{userinfoBean.userinfo.age}" label="用户年龄">
					<f:validateDoubleRange minimum="1" maximum="99" />
				</p:inputText>
				
				<h:outputText value="电子邮箱：" />
				<p:inputText value="#{userinfoBean.userinfo.email}" validatorMessage="电子邮箱：请输入正确的Email地址。" maxlength="20">
					<f:validateRegex pattern="#{regex.EMAIL}" />
				</p:inputText>
				
				<h:outputText value="联系电话：" />
				<p:inputText value="#{userinfoBean.userinfo.phone}" maxlength="20" label="联系电话" id="phone">
					<f:validator validatorId="customValidator" />
					<f:attribute name="empty" value="true" />
					<f:attribute name="regex" value="PHONE" />
				</p:inputText>
				
				<h:outputText value="用户性别：" />
				<p:selectOneRadio value="#{userinfoBean.sex}" required="true" label="用户性别">
					<f:selectItem itemLabel="男" itemValue="男" />
					<f:selectItem itemLabel="女" itemValue="女" />
				</p:selectOneRadio>

				<h:outputText value="是否有效：" />
				<p:selectOneRadio value="#{userinfoBean.usable}"  required="true" label="是否有效">
					<f:selectItem itemLabel="可用" itemValue="Y" />
					<f:selectItem itemLabel="禁用" itemValue="N" />
				</p:selectOneRadio> 
			</h:panelGrid>
			<h:panelGrid columns="4"
				columnClasses="column1">	
				<h:outputText value="用户地址：" />
				<p:inputText value="#{userinfoBean.userinfo.address}" maxlength="30" id="address"/>
				
			</h:panelGrid>
			<p:spacer width="10px" height="10px"></p:spacer> 

			<div align="center">
				<p:commandButton value="修改"  icon="ui-icon ui-icon-check"  style="margin-right:5px"  rendered="#{userinfoBean.isModify}" 
					actionListener="#{userinfoBean.sumbitDlgData()}"   
					oncomplete="aboutMeRequest(xhr, status, args);getWidth();"  
					update=":userinfoFormId,:userdataFormId"  />
				<p:commandButton value="添加"  icon="ui-icon ui-icon-check"  style="margin-right:5px"  rendered="#{!userinfoBean.isModify}"  
					actionListener="#{userinfoBean.sumbitDlgData()}"   
					oncomplete="aboutMeRequest(xhr, status, args);getWidth();"  
					update=":userinfoFormId,:userdataFormId"  />
				<p:commandButton type="button" value="取消"  onclick="userdataDlgVar.hide();getWidth();"  icon="ui-icon ui-icon-cancel" />
			</div>

		</h:form>
		<script type="text/javascript">
			function aboutMeRequest(xhr, status, args) {
				if (args.aboutMeAddInfo == "Y") {
					userdataDlgVar.hide();
				}
			}
			function getWidth(){
				var width=$("#phone").width();
				$("#address").width((width+width+88));
			}
		</script>
	</p:dialog>
</ui:composition>
